package cn.lystudio.rohmtimeopwide_background_v11.service.impl;

import cn.lystudio.rohmtimeopwide_background_v11.entity.po.QrTypePO;
import cn.lystudio.rohmtimeopwide_background_v11.mapper.QrTypePOMapper;
import cn.lystudio.rohmtimeopwide_background_v11.service.QrTypeService;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
@Slf4j
@DS("master")

public class QrTypeServiceImpl implements QrTypeService {
    @Resource
    private QrTypePOMapper qrTypePOMapper;
    @Override
    public List<QrTypePO> getAll() {
        LambdaQueryWrapper<QrTypePO> wrapper = new LambdaQueryWrapper<>();
        wrapper.orderByAsc(QrTypePO::getQrTypeID);
        return qrTypePOMapper.selectList(wrapper);
    }

    @Override
    public int uptQrTypeEnabled(Integer qrTypeID, Boolean enabled) {
        QrTypePO qrTypePO = new QrTypePO();
        qrTypePO.setQrTypeID(qrTypeID);
        qrTypePO.setEnabled(enabled);
        return qrTypePOMapper.updateById(qrTypePO);
    }

    @Override
    public int delQrType(Integer qrTypeID) {
        return qrTypePOMapper.deleteById(qrTypeID);
    }

    @Override
    public int addQrType(QrTypePO qrTypePO) {
        return qrTypePOMapper.insert(qrTypePO);
    }

    @Override
    public int uptQrType(QrTypePO qrTypePO) {
        return qrTypePOMapper.updateById(qrTypePO);
    }

    @Override
    public QrTypePO get1ByID(Integer qrTypeID) {
        return qrTypePOMapper.selectById(qrTypeID);
    }
}
